home *** CD-ROM | disk | FTP | other *** search
- Path: news.iag.net!news
- From: jatmon@iag.net (John R Buchan)
- Newsgroups: comp.lang.c
- Subject: Re: Help!
- Date: 26 Jan 1996 15:42:59 GMT
- Organization: Internet Access Group, Orlando, Florida
- Message-ID: <4easq3$irl@news.iag.net>
- References: <4ea5p4$j0s@ratree.psu.ac.th>
- NNTP-Posting-Host: pm3-orl27.iag.net
- X-Newsreader: WinVN 0.99.7
-
- In article <4ea5p4$j0s@ratree.psu.ac.th>, s3610165@maliwan.psu.ac.th says...
- >
- >Dear all
- >
- > There is a file, hi.bat, in my 'h:\data' directory and I try to
- >run it by C program but it fail. Please, advice to me?
- >
- >Source:
- >
- >#include<stdio.h>
- >#include<stdlib.h>
- >#include<conio.h>
- >#include<dir.h>
- >
- >main()
- >{
- >clrscr();
- >chdir("h:\data");
- >system("hi.bat");
- >getch();
- >}
-
- It would help to have some idea of what happens when it fails (eg, what
- error message do you get?). However, one apparent problem in the code is
- the chdir statement. Since, I am not aware of any character constant '\d',
- I am assuming that you are trying to include a backslash in the string.
- The backslash is an escape character in strings ( it is used to indicate
- that the next character(s) has some special meaning), you need to use a
- double backslash '\\' to actually include one in a string. Look up the
- character constants in your manual or help system. Try:
-
- chdir("h:\\data");
-
- Another option is to use a slash instead. Only DOS's command line requires
- the backslash.
-
- chdir("h:/data");
-
- --
- John R Buchan -:|:- Looking for that elusive FAQ? ftp to:
- jatmon@mail.iag.net -:|:- rtfm.mit.edu /pub/usenet-by-group/....
-
-